package com.c.ctgproject.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.SingleCarPartEntity
import com.c.ctgproject.utils.handlerNull

/**
 *作者:LiBW
 *创建日期: 2020/9/8
 *描述: 单车已销售配件适配器
 */
class SingleCarPartAdapter(private val context: Context, private val mList: List<SingleCarPartEntity.DataBean.ListBean>) : RecyclerView.Adapter<SingleCarPartAdapter.ViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SingleCarPartAdapter.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_single_car_part_list, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: SingleCarPartAdapter.ViewHolder, position: Int) {
        val data = mList[position]
        //时间
        holder.mTimeTV.text=data.outTime.handlerNull()
        //货品名
        holder.mNameTV.text=data.partsName.handlerNull()
        //基础价格
        holder.mPriceTV.text=data.partsPrice.handlerNull()
        //销售员
        holder.mSellerTV.text=data.userName.handlerNull()
        //数量
        holder.partsNumber.text=data.partsNumber.handlerNull()
    }

    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val mTimeTV: TextView = view.findViewById(R.id.mTimeTV)
        val mNameTV: TextView = view.findViewById(R.id.mNameTV)
        val mPriceTV: TextView = view.findViewById(R.id.mPriceTV)
        val mSellerTV: TextView = view.findViewById(R.id.mSellerTV)
        val partsNumber: TextView = view.findViewById(R.id.partsNumber)
    }
}